package bsc.ejb.entity;

import bsc.ejb.entity.DimensionalCut.Type;
import java.io.Serializable;
import java.util.Collection;
import java.util.List;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Enumerated;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.JoinTable;
import javax.persistence.ManyToMany;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;

/**
 *
 * @author memozac
 */
@Entity
public class DimensionMember implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @GeneratedValue(strategy = GenerationType.AUTO)
    private Long idDimensionMember;

    @Column(columnDefinition="text")
    private String name;

    @Enumerated
    private DimensionalCut.Type type;

    @ManyToOne
    private Dimension dimension;

    @ManyToOne
    private DimensionMember dimensionMember;

    @OneToMany
    private List<DimensionMember> dimensionMembers;

    @ManyToMany(targetEntity=DimensionalCut.class) @JoinTable(name="DimensionalCutMember", joinColumns=@JoinColumn(name="idDimensionMember"),
    inverseJoinColumns=@JoinColumn(name="idScoreCard")) private Collection<DimensionalCut> dimensionalCuts;

    public Collection<DimensionalCut> getDimensionalCuts() {
        return dimensionalCuts;
    }

    public void setDimensionalCuts(Collection<DimensionalCut> dimensionalCuts) {
        this.dimensionalCuts = dimensionalCuts;
    }

    public DimensionMember getDimensionMember() {
        return dimensionMember;
    }

    public Type getType() {
        return type;
    }

    public void setType(Type type) {
        this.type = type;
    }

    public void setDimensionMember(DimensionMember dimensionMember) {
        this.dimensionMember = dimensionMember;
    }

    public List<DimensionMember> getDimensionMembers() {
        return dimensionMembers;
    }

    public void setDimensionMembers(List<DimensionMember> dimensionMembers) {
        this.dimensionMembers = dimensionMembers;
    }

    public Dimension getDimension() {
        return dimension;
    }

    public void setDimension(Dimension dimension) {
        this.dimension = dimension;
    }

    public Long getIdDimensionMember() {
        return idDimensionMember;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (idDimensionMember != null ? idDimensionMember.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        if (!(object instanceof DimensionMember)) {
            return false;
        }
        DimensionMember other = (DimensionMember) object;
        if ((this.idDimensionMember == null && other.idDimensionMember != null) || (this.idDimensionMember != null && !this.idDimensionMember.equals(other.idDimensionMember))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "bsc.ejb.entity.DimensionMember[id=" + idDimensionMember + "]";
    }

    /**
     * @return the name
     */
    public String getName() {
        return name;
    }

    /**
     * @param name the name to set
     */
    public void setName(String name) {
        this.name = name;
    }

}//ends of class
